ostree.git
6 years agosign: allow to sign commits from CLI
Denis Pynkin [Wed, 31 Jul 2019 01:00:19 +0000 (04:00 +0300)]
sign: allow to sign commits from CLI

Add signing ability to commit builtin.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
6 years agosign: add new builtin for signing
Denis Pynkin [Tue, 30 Jul 2019 22:13:48 +0000 (01:13 +0300)]
sign: add new builtin for signing

This builtin allows to sign and verify commit with new signature
mechanism. At the moment it is possible to use 'dummy' and 'ed25519'
signing modules.

'dummy' module use any ASCII string from command line as a key for
commit's signing or verification.

Support of ed25519 signature is implemented with `libsoium` library.
Secret and public key should be provided in hex presentation via
command line.

Based on 'gpg-sign' source.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
6 years agolib/sign: initial implementation
Denis Pynkin [Sun, 28 Jul 2019 23:32:28 +0000 (02:32 +0300)]
lib/sign: initial implementation

Added the initial version of signing interface allowing to allowing to
sign and verify commits.
Implemented initial signing modules:
 - dummy -- simple module allowing to sign/verify with ASCII string
 - ed25519 -- module allowing to sign/verify commit with ed25519
   (EdDSA) signature scheme provided by libsodium library.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
6 years agoAdd libsodium dependency
Denis Pynkin [Sat, 15 Jun 2019 17:10:47 +0000 (20:10 +0300)]
Add libsodium dependency

Allow to configure with libsodium flag.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
6 years agoMerge pull request #2041 from cgwalters/auto-sepolicy
OpenShift Merge Robot [Tue, 24 Mar 2020 19:06:55 +0000 (20:06 +0100)]
Merge pull request #2041 from cgwalters/auto-sepolicy

 repo/commit: Add support for --selinux-policy-from-base

6 years agorepo/commit: Add support for --selinux-policy-from-base
Colin Walters [Sat, 21 Mar 2020 14:48:24 +0000 (14:48 +0000)]
repo/commit: Add support for --selinux-policy-from-base

The [dev-overlay](https://github.com/coreos/coreos-assembler/blob/332c6ab3b91778d904224c3c960d9cc4739d60bd/src/cmd-dev-overlay)
script shipped in coreos-assembler mostly exists to deal
with the nontrivial logic around SELinux policy.  Let's make
the use case of "commit some binaries overlaying a base tree, using
the base's selinux policy" just require a magical
`--selinux-policy-from-base` argument to `ostree commit`.

A new C API was added to implement this in the case of `--tree=ref`;
when the base directory is already checked out, we can just reuse
the existing logic that `--selinux-policy` was using.

Requires: https://github.com/ostreedev/ostree/pull/2039

6 years agoMerge pull request #2042 from cgwalters/pull-repeated-no-flake
OpenShift Merge Robot [Tue, 24 Mar 2020 15:49:14 +0000 (16:49 +0100)]
Merge pull request #2042 from cgwalters/pull-repeated-no-flake

tests/pull-repeated: Bump up retries to match max fails

6 years agotests/pull-repeated: Bump up retries to match max fails
Colin Walters [Tue, 24 Mar 2020 12:24:46 +0000 (12:24 +0000)]
tests/pull-repeated: Bump up retries to match max fails

This test keeps occasionally failing in CI - as expected, because
we retry 8 times for an object but it's completely possible for
us to hit the <0.5% chance of 50% failure 8 times in a row.

Since the max errors from the server is 100, set retries to the
same thing.

6 years agoMerge pull request #2039 from cgwalters/commit-cli-cleanup
OpenShift Merge Robot [Tue, 24 Mar 2020 01:22:22 +0000 (02:22 +0100)]
Merge pull request #2039 from cgwalters/commit-cli-cleanup

main/commit: Rework control flow to use --tree=X path

6 years agomain/commit: Rework control flow to use --tree=X path
Colin Walters [Sat, 21 Mar 2020 17:54:13 +0000 (17:54 +0000)]
main/commit: Rework control flow to use --tree=X path

Rework the simple cases of "commit ." and "commit argv[1]" to
generate the more general "--tree=X --tree=Y" path, so that we
only have one primary control flow here.

Prep for a future patch around loading SELinux policy from
the first argument.

6 years agoMerge pull request #2040 from cgwalters/itest-require-writable
OpenShift Merge Robot [Mon, 23 Mar 2020 19:01:04 +0000 (20:01 +0100)]
Merge pull request #2040 from cgwalters/itest-require-writable

tests/kola: Two test fixes

6 years agotests/kola: Two test fixes
Colin Walters [Sat, 21 Mar 2020 20:39:18 +0000 (20:39 +0000)]
tests/kola: Two test fixes

Now that we're actually running this in CI.

6 years agoMerge pull request #2037 from mwleeds/retry-on-partial-input
OpenShift Merge Robot [Fri, 20 Mar 2020 13:35:14 +0000 (14:35 +0100)]
Merge pull request #2037 from mwleeds/retry-on-partial-input

lib/fetcher-util: retry download on G_IO_ERROR_PARTIAL_INPUT

6 years agolib/fetcher-util: retry download on G_IO_ERROR_PARTIAL_INPUT
Matthew Leeds [Thu, 19 Mar 2020 22:28:08 +0000 (15:28 -0700)]
lib/fetcher-util: retry download on G_IO_ERROR_PARTIAL_INPUT

Add G_IO_ERROR_PARTIAL_INPUT to the list of error codes caused by
transient networking errors which lead us to retry the request. When
attempting to install the spotify flatpak you often get the error
message "Connection terminated unexpectedly" and the download of the deb
file fails. In this case, libsoup is setting G_IO_ERROR_PARTIAL_INPUT
and sometimes a subsequent download attempt is successful, so we should
treat it as transient.

Ideally we would behave as wget does in this case and retry the download
picking up where we left off in the file rather than starting over, but
that would require changes to libsoup I think.

Sadly this patch does not fix the flatpak installation of spotify in the
face of such errors, because flatpak doesn't use libostree to download
extra data, but presumably it's possible we could encounter such an
error pulling from an ostree repo, so the patch is still correct.

6 years agoMerge pull request #2036 from jlebon/pr/partial-parent
OpenShift Merge Robot [Thu, 19 Mar 2020 17:05:00 +0000 (18:05 +0100)]
Merge pull request #2036 from jlebon/pr/partial-parent

lib/pull: Don't leave commits pulled by depth as partial

6 years agoMerge pull request #2025 from cgwalters/use-kola-run-ext
OpenShift Merge Robot [Thu, 19 Mar 2020 16:32:23 +0000 (17:32 +0100)]
Merge pull request #2025 from cgwalters/use-kola-run-ext

tests: Rework tests/installed → tests/kola

6 years agotests: Rework tests/installed → tests/kola
Colin Walters [Wed, 11 Mar 2020 20:00:14 +0000 (20:00 +0000)]
tests: Rework tests/installed → tests/kola

Previously we made an effort to use the [Fedora Standard Test Interface](https://docs.fedoraproject.org/en-US/ci/standard-test-interface/).
This effort was not very successful; the primary thing that
it really died on is Ansible just didn't support rebooting
very well.  I think that's since gotten better, but even
then, Ansible wasn't the best thing for a test framework
for us anyways.

In the meantime Fedora CoreOS happened emphasizing Ignition
and not "post-hoc reconciliation" models like Ansible over
ssh.

And, [coreos-assembler](https://github.com/coreos/coreos-assembler) happened too.

Furthermore, we really need to test OSTree's interaction
with Ignition as we've invented several special things there.

Then most recently, I've been working on having
cosa/kola support running externally defined tests:
https://github.com/coreos/coreos-assembler/pull/1215

There's a lot of things to clean up after this but at least this
works for me:

```
$ cd /srv/fcos
$ cosa kola run -- --parallel 4 --output-dir tmp/kola -E ~/src/github/ostreedev/ostree/ 'ext.ostree.*'
```

NOTE: This *does not* drop ostree binaries into the target.  See:
https://github.com/coreos/coreos-assembler/pull/1252#issuecomment-600623315

This drops our dependency on Python in the installed tests, and
also fixes a few bugs that came up.

I disabled the `itest-bare-user-root.sh` one because it's
entangled with the shell script infrastructure for the unit tests.

6 years agolib/pull: Don't leave commits pulled by depth as partial
Jonathan Lebon [Thu, 19 Mar 2020 14:05:57 +0000 (10:05 -0400)]
lib/pull: Don't leave commits pulled by depth as partial

When pulling full parent commits via e.g. `--depth N`, we weren't
unmarking them as partial in the out path.

Closes: #2035
6 years agoMerge pull request #2034 from jlebon/pr/diff-docs
OpenShift Merge Robot [Thu, 19 Mar 2020 00:06:15 +0000 (01:06 +0100)]
Merge pull request #2034 from jlebon/pr/diff-docs

bin/diff: Clarify documentation around REV and DIR syntax

6 years agobin/diff: Clarify documentation around REV and DIR syntax
Jonathan Lebon [Wed, 18 Mar 2020 14:32:52 +0000 (10:32 -0400)]
bin/diff: Clarify documentation around REV and DIR syntax

Related: #2032

6 years agoMerge pull request #2033 from cgwalters/pin-error-handling
OpenShift Merge Robot [Wed, 18 Mar 2020 13:42:42 +0000 (14:42 +0100)]
Merge pull request #2033 from cgwalters/pin-error-handling

main/pin: Fix usage of GError

6 years agomain/pin: Fix usage of GError
Colin Walters [Wed, 18 Mar 2020 02:13:15 +0000 (02:13 +0000)]
main/pin: Fix usage of GError

This regressed in https://github.com/ostreedev/ostree/commit/2db79fb398fba2f9ab2e05c517ebccfe1834674b
I noticed this while finally getting the installed tests to run
in FCOS via kola and `ostree admin pin 0` is now aborting because
we were returning TRUE, but no error set.

I don't see a reason to try to continue on if we hit an error;
the original reporter was requesting support for multiple arguments,
but not "ignore invalid requests".

6 years agoMerge pull request #2030 from jlebon/pr/2020.3
OpenShift Merge Robot [Sat, 14 Mar 2020 15:17:21 +0000 (16:17 +0100)]
Merge pull request #2030 from jlebon/pr/2020.3

Release 2020.3

6 years agoPost-release version bump
Jonathan Lebon [Sat, 14 Mar 2020 01:56:14 +0000 (21:56 -0400)]
Post-release version bump

6 years agoRelease 2020.3
Jonathan Lebon [Sat, 14 Mar 2020 01:54:21 +0000 (21:54 -0400)]
Release 2020.3

Let's do another release to get the `sysroot.readonly` fixes into FCOS
and unpin ostree and rpm-ostree there.

6 years agoMerge pull request #2027 from cgwalters/pull-auto-mnt-namespace
OpenShift Merge Robot [Sat, 14 Mar 2020 01:52:43 +0000 (02:52 +0100)]
Merge pull request #2027 from cgwalters/pull-auto-mnt-namespace

main: Also automatically remount rw /sysroot for `ostree pull` etc.

6 years agomain: Also automatically remount rw /sysroot for `ostree pull` etc.
Colin Walters [Thu, 12 Mar 2020 21:10:29 +0000 (21:10 +0000)]
main: Also automatically remount rw /sysroot for `ostree pull` etc.

See https://github.com/coreos/fedora-coreos-tracker/issues/343
When we added the read-only sysroot support it broke using "raw"
`ostree pull` and `ostree refs --create` and all of the core repo
CLIs that just operate on a repo and not a sysroot.

Fixing this is a bit ugly as it "layer crosses" things even more.
Extract a helper function that works in both cases.

6 years agoMerge pull request #2029 from jlebon/pr/upgrade-tests
OpenShift Merge Robot [Fri, 13 Mar 2020 20:53:04 +0000 (21:53 +0100)]
Merge pull request #2029 from jlebon/pr/upgrade-tests

ci: use `fcosKola` for running kola tests

6 years agoci: use `fcosKola` for running kola tests
Jonathan Lebon [Fri, 13 Mar 2020 18:35:53 +0000 (14:35 -0400)]
ci: use `fcosKola` for running kola tests

We were using `--no-test-exit-error` for upgrade tests but weren't
actually checking for test failures after.

Instead of running kola directly, just use the `fcosKola` custom step
which automatically takes care of e.g. running tests in parallel and
archiving results.

6 years agoMerge pull request #2028 from cgwalters/ci-test-upgrades
OpenShift Merge Robot [Fri, 13 Mar 2020 18:18:40 +0000 (19:18 +0100)]
Merge pull request #2028 from cgwalters/ci-test-upgrades

ci: Test kola --upgrades

6 years agoci: Test kola --upgrades
Colin Walters [Fri, 13 Mar 2020 17:29:58 +0000 (17:29 +0000)]
ci: Test kola --upgrades

This one is very relevant for ostree.

6 years agoMerge pull request #2018 from jlebon/pr/migrate-to-coreos-ci
OpenShift Merge Robot [Wed, 4 Mar 2020 22:32:56 +0000 (17:32 -0500)]
Merge pull request #2018 from jlebon/pr/migrate-to-coreos-ci

ci: migrate to new coreos-ci project

6 years agoci: migrate to new coreos-ci project
Jonathan Lebon [Mon, 2 Mar 2020 19:22:14 +0000 (14:22 -0500)]
ci: migrate to new coreos-ci project

Use the new custom steps. I think we could simplify things further by
using `fcosBuild` but let's start with this for now.

6 years agoMerge pull request #2015 from cgwalters/release
OpenShift Merge Robot [Fri, 21 Feb 2020 15:16:50 +0000 (10:16 -0500)]
Merge pull request #2015 from cgwalters/release

Release 2020.2

6 years agoPost-release version bump
Colin Walters [Fri, 21 Feb 2020 14:48:00 +0000 (14:48 +0000)]
Post-release version bump

6 years agoRelease 2020.2
Colin Walters [Fri, 21 Feb 2020 14:39:14 +0000 (14:39 +0000)]
Release 2020.2

"Brown paper bag" release that actually sets the
`is_release_build=yes` flag and also fixes the
`Since:` on a few new functions.

6 years agoMerge pull request #2014 from ostreedev/fixup-since-versions
OpenShift Merge Robot [Thu, 20 Feb 2020 23:27:28 +0000 (18:27 -0500)]
Merge pull request #2014 from ostreedev/fixup-since-versions

lib: Fix Since versions for 2020.1

6 years agolib: Fix Since versions for 2020.1
Dan Nicholson [Thu, 20 Feb 2020 22:44:51 +0000 (15:44 -0700)]
lib: Fix Since versions for 2020.1

These had been added assuming 2019.7 would be the next version, but now
it's 2020 and there's been a release. In the case of
`OstreeCommitSizesEntry`, I'd forgotten to move it forward from 2019.5
to 2019.7 in the time between when I started working on the feature and
it landed.

6 years agoMerge pull request #2013 from cgwalters/prepareroot-comment
OpenShift Merge Robot [Thu, 20 Feb 2020 17:30:05 +0000 (18:30 +0100)]
Merge pull request #2013 from cgwalters/prepareroot-comment

prepare-root: Add a comment about the role of this service

6 years agoPost-release version bump
Colin Walters [Thu, 20 Feb 2020 16:37:07 +0000 (16:37 +0000)]
Post-release version bump

6 years agoRelease 2020.1
Colin Walters [Thu, 20 Feb 2020 16:16:19 +0000 (16:16 +0000)]
Release 2020.1

New year, new release!

6 years agoMerge pull request #1984 from jlebon/pr/supp-groups
OpenShift Merge Robot [Thu, 20 Feb 2020 02:07:41 +0000 (03:07 +0100)]
Merge pull request #1984 from jlebon/pr/supp-groups

lib/repo: Create repo directories as 0775

6 years agoprepare-root: Add a comment about the role of this service
Colin Walters [Thu, 20 Feb 2020 00:33:01 +0000 (00:33 +0000)]
prepare-root: Add a comment about the role of this service

Came up on an IRC question, docs for this are scattered around.

6 years agoMerge pull request #2012 from clime/patch-2
OpenShift Merge Robot [Wed, 19 Feb 2020 19:32:23 +0000 (20:32 +0100)]
Merge pull request #2012 from clime/patch-2

Update ostree-pull.xml with info about pulled refs location and access

6 years agoUpdate ostree-pull.xml with info about pulled refs location and access
clime [Tue, 18 Feb 2020 20:46:22 +0000 (21:46 +0100)]
Update ostree-pull.xml with info about pulled refs location and access

6 years agolib/repo: Create repo directories as 0775
Jonathan Lebon [Thu, 12 Dec 2019 21:40:33 +0000 (16:40 -0500)]
lib/repo: Create repo directories as 0775

For repo structure directories like `objects`, `refs`, etc... we should
be more permissive and let the system's `umask` narrow down the
permission bits as wanted.

This came up in a context where we want to be able to have read/write
access on an OSTree repo on NFS from two separate OpenShift apps by
using supplemental groups[1] so we don't require SCCs for running as the
same UID (supplemental groups are part of the default restricted SCC).

[1] https://docs.openshift.com/container-platform/3.11/install_config/persistent_storage/persistent_storage_nfs.html#nfs-supplemental-groups

6 years agoMerge pull request #2009 from cgwalters/testsuite
OpenShift Merge Robot [Fri, 14 Feb 2020 21:56:25 +0000 (22:56 +0100)]
Merge pull request #2009 from cgwalters/testsuite

deploy: Avoid trying to change immutable state unnecessarily

6 years agodeploy: Avoid trying to change immutable state unnecessarily
Colin Walters [Fri, 14 Feb 2020 16:35:50 +0000 (16:35 +0000)]
deploy: Avoid trying to change immutable state unnecessarily

For some reason I haven't fully debugged (probably a recent
kernel change), in the case where the immutable bit isn't set,
trying to call `EXT2_IOC_SETFLAGS` without it set returns `EINVAL`.

Let's avoid calling the `ioctl()` if we don't have anything to do.

This fixes a slew of `make check` failures here in my toolbox
environment.

(kernel is `5.5.0-0.rc6.git0.1.fc32.x86_64` with `xfs`)

6 years agoMerge pull request #2003 from crobinso/doc-link-fix
OpenShift Merge Robot [Mon, 10 Feb 2020 19:28:40 +0000 (20:28 +0100)]
Merge pull request #2003 from crobinso/doc-link-fix

docs: Fix 'package layering' rpm-ostree link

6 years agodocs: Fix 'package layering' rpm-ostree link
Cole Robinson [Mon, 10 Feb 2020 19:00:11 +0000 (14:00 -0500)]
docs: Fix 'package layering' rpm-ostree link

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoMerge pull request #1999 from cgwalters/cci-2
OpenShift Merge Robot [Fri, 7 Feb 2020 14:08:05 +0000 (15:08 +0100)]
Merge pull request #1999 from cgwalters/cci-2

ci: Replace PAPR with CoreOS CI

6 years agoci: Replace PAPR with CoreOS CI
Colin Walters [Mon, 3 Feb 2020 20:45:07 +0000 (20:45 +0000)]
ci: Replace PAPR with CoreOS CI

Move the alternative builds into the Jenkinsfile.

Update it to do a FCOS build + kola run.

We drop the flatpak/rpm-ostree runs for now; the former
will needs some work to do the automatic virt bits.  The
latter I think we can circle back to when we e.g. figure
out how to include rpm-ostree's tests in kola runs.

6 years agoMerge pull request #2000 from cgwalters/soup-travis
OpenShift Merge Robot [Mon, 3 Feb 2020 21:56:55 +0000 (13:56 -0800)]
Merge pull request #2000 from cgwalters/soup-travis

travis: Update debian/ubuntu environments

6 years agotravis: Update debian/ubuntu environments
Colin Walters [Mon, 3 Feb 2020 21:03:17 +0000 (21:03 +0000)]
travis: Update debian/ubuntu environments

There are new major LTS environments out; bump up to the latest
for each and drop the old Ubuntu trusty.  Part of cleaning up
our CI.

6 years agoMerge pull request #1998 from cgwalters/cci-jenkinsfile
OpenShift Merge Robot [Mon, 3 Feb 2020 18:42:55 +0000 (10:42 -0800)]
Merge pull request #1998 from cgwalters/cci-jenkinsfile

Add .cci.jenkinsfile

6 years agoAdd .cci.jenkinsfile
Colin Walters [Mon, 3 Feb 2020 15:42:28 +0000 (15:42 +0000)]
Add .cci.jenkinsfile

See https://github.com/jlebon/coreos-ci

This is just a start to test, cut down from the rpm-ostree version.

6 years agoMerge pull request #1959 from cgwalters/ostree-verity
OpenShift Merge Robot [Tue, 28 Jan 2020 21:01:40 +0000 (13:01 -0800)]
Merge pull request #1959 from cgwalters/ostree-verity

Initial fs-verity support

6 years agoMerge pull request #1957 from dbnicholson/commit-sizes
OpenShift Merge Robot [Mon, 27 Jan 2020 16:25:59 +0000 (08:25 -0800)]
Merge pull request #1957 from dbnicholson/commit-sizes

Upstream Endless sizes metadata changes

6 years agoInitial fs-verity support
Colin Walters [Fri, 25 Oct 2019 22:07:44 +0000 (22:07 +0000)]
Initial fs-verity support

Using fs-verity is natural for OSTree because it's file-based,
as opposed to block based (like dm-verity).  This only covers
files - not symlinks or directories.  And we clearly need to
have integrity for the deployment directories at least.

Also, what we likely need is an API that supports signing files
as they're committed.

So making this truly secure would need a lot more work.  Nevertheless,
I think it's time to start experimenting with it.  Among other things,
it does *finally* add an API that makes files immutable, which will
help against some accidental damage.

This is basic enablement work that is being driven by
Fedora CoreOS; see also https://github.com/coreos/coreos-assembler/pull/876

6 years agoMerge pull request #1877 from dbnicholson/specific-gpg-errors
OpenShift Merge Robot [Sun, 26 Jan 2020 17:20:51 +0000 (09:20 -0800)]
Merge pull request #1877 from dbnicholson/specific-gpg-errors

More specific GPG errors

6 years agoMerge pull request #1996 from akiernan/us-with-systemd
OpenShift Merge Robot [Sun, 26 Jan 2020 12:19:31 +0000 (04:19 -0800)]
Merge pull request #1996 from akiernan/us-with-systemd

build: fix systemd feature advertisement

6 years agobuild: fix systemd feature advertisement
Alex Kiernan [Tue, 21 Jan 2020 12:37:52 +0000 (12:37 +0000)]
build: fix systemd feature advertisement

17db0f15a798 ("configure: add option for libsystemd") exposed
--without-libsystemd to allow systemd to be disabled even if the systemd
pkgconfig script was present, introducing a new variable
with_libsystemd; there are now three, almost identical variables:

- with_libsystemd [yes, no, maybe] - controlled by --without-libsystemd,
  resolved into yes/no by the initial checks
- have_libsystemd [yes, no, <undefined>] - only set if with_libsystemd
  is yes/maybe, otherwise undefined
- with_systemd [yes, <undefined>] - yes if have_systemd is yes,
  otherwise undefined

with_systemd is the earliest variable and was previously set by a set of
checks for dracut and mkinitcpio. These checks were changed for a
systemd check in 9e2763106be0 ("lib: Use sd_journal directly
(optionally)"). This commit also introduced BUILDOPT_LIBSYSTEMD, which
will always match BUILDOPT_SYSTEMD.

Fix the confusion by removing with_systemd which will always be yes when
with_libsystemd=yes, or undefined if with_libsystemd=no. We can ignore
the with_libsystemd=maybe case because it will always be resolved into
yes/no before with_systemd is set.

And replace all uses of BUILDOPT_SYSTEMD with BUILDOPT_LIBSYSTEMD, since
they again always match.

This fixes both the advertised features and the summary output when
systemd is disabled by using with_libsystemd which is always defined.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Fixes: 5c62a7e4d0a5 ("build: Expose systemd in OSTREE_FEATURES")
Fixes: 17db0f15a798 ("configure: add option for libsystemd")
Supersedes: #1992

6 years agoMerge pull request #1948 from dbnicholson/trivial-httpd-autoexit
OpenShift Merge Robot [Fri, 24 Jan 2020 20:42:59 +0000 (12:42 -0800)]
Merge pull request #1948 from dbnicholson/trivial-httpd-autoexit

ostree/trivial-httpd: Fix --autoexit with --daemonize and --log-file

6 years agoostree/trivial-httpd: Add log message for autoexit
Dan Nicholson [Fri, 18 Oct 2019 16:50:39 +0000 (10:50 -0600)]
ostree/trivial-httpd: Add log message for autoexit

This is useful when checking if the daemon actually exited since we
don't store the child PID anywhere.

6 years agoostree/trivial-httpd: Fix --autoexit with --daemonize and --log-file
Dan Nicholson [Fri, 18 Oct 2019 16:33:02 +0000 (10:33 -0600)]
ostree/trivial-httpd: Fix --autoexit with --daemonize and --log-file

When --autoexit is used with --daemonize and --log-file, the program
never exits when the root directory is deleted. I believe what happens
is that g_file_new_for_path triggers the glib worker context to be
started to talk to GVfs. Once the program forks, the parent exits and
the thread iterating the worker context is gone. The file monitor then
never receives any events because the inotify helper also runs from the
worker context.

Move the fork earlier just after parsing and validating the command line
arguments. In order to handle setup errors in the child, a pipe is
opened and the parents waits until the child writes a status byte to it.
If the byte is 0, the parent considers the child setup successful and
exits and the child carries on as a daemon. Notably, the child doesn't
reopen stderr to /dev/null until after this so that it can send error
messages there.

Fixes: #1941
6 years agoci/flatpak: Patch GPG error assertions from OSTree
Dan Nicholson [Tue, 21 Jan 2020 22:47:01 +0000 (15:47 -0700)]
ci/flatpak: Patch GPG error assertions from OSTree

Some of the flatpak tests assert on GPG error strings that come from
OSTree. Those are being changed here, so patch the cloned flatpak 1.4.1
to accommodate the new error strings. When this work lands, I'll send a
patch upstream to flatpak that will eventually trickle back here in a
tagged build.

6 years agotests/gpg: Add tests for importing updated remote GPG keys
Dan Nicholson [Fri, 21 Jun 2019 11:59:56 +0000 (06:59 -0500)]
tests/gpg: Add tests for importing updated remote GPG keys

This checks whether gpg-import will properly update the keyring for a
key that already exists. In particular, we check that changing the key
expiration time or revoking it results in commit verification failure
after re-importing the keys.

6 years agotests/gpg: Test ostree_gpg_verify_result_require_valid_signature
Dan Nicholson [Fri, 21 Jun 2019 11:16:13 +0000 (06:16 -0500)]
tests/gpg: Test ostree_gpg_verify_result_require_valid_signature

Add explicit tests for
`ostree_gpg_verify_result_require_valid_signature` in addition to the
implicit tests via `ostree pull` and others. This allows checking the
error code raised.

6 years agolib/gpg: Add more specific OstreeGpgError codes
Dan Nicholson [Sat, 15 Jun 2019 14:56:44 +0000 (09:56 -0500)]
lib/gpg: Add more specific OstreeGpgError codes

Currently `ostree_gpg_verify_result_require_valid_signature` always
returns an error that the key used for the signature is missing from the
keyring. However, all that's been determined is that there are no valid
signatures. The error could also be from an expired signature, an
expired key, a revoked key or an invalid signature.

Provide values for these missing errors and return them from
`ostree_gpg_verify_result_require_valid_signature`. The description of
each result is appended to the error message, but since the result can
contain more than one signature but only a single error can be returned,
the status of the last signature is used for the error code. See the
comment for rationale.

Related: flatpak/flatpak#1450

6 years agotests/test-gpg-verify-result: Allow specifying signature files
Dan Nicholson [Thu, 20 Jun 2019 14:32:13 +0000 (09:32 -0500)]
tests/test-gpg-verify-result: Allow specifying signature files

Currently tests are always run against the full lgpl2.sig file with all
signatures, but it should also be possible to specify one or more of the
individual lgpgl2.sig<N> files.

Drop the current usage of passing the signature index in the test data
since it's always specific to the test function and instead provide an
optional array of signature files for the test fixture to sign with.

6 years agotests/gpg-verify-data: Empty out trustdb.gpg
Dan Nicholson [Fri, 21 Jun 2019 12:09:43 +0000 (07:09 -0500)]
tests/gpg-verify-data: Empty out trustdb.gpg

When the private keys were generated, gpg added an ultimate trust entry
since you normally want to trust your own keys. However, this throws off
the expired signature testing since gpgme considers it valid if the key
is fully or ultimately trusted.

The use of a trustdb for the test-gpg-verify-result is unlike any other
GPG verification in ostree. Under normal circumstances, a temporary GPG
homedir is created without any trust information, so all keys are
treated as having unknown trust.

Regenerate an empty trustdb.gpg in gpg-verify-data so that the tests
behave as ostree normally operates. After this the expired signature
testing correctly shows up as a non-valid signature. The trustdb was
regenerated by simply removing it and running any gpg operation with the
gpg-verify-data directory as the homedir.

6 years agotests/gpg-verify-data: Split out signature data
Dan Nicholson [Wed, 19 Jun 2019 21:31:18 +0000 (16:31 -0500)]
tests/gpg-verify-data: Split out signature data

The full block with all 5 signatures remains, but this allows passing
individual signatures through the GPG verification APIs. The split was
done with `gpgsplit`, and looking at the output of `gpg --list-packets`
of the split and unsplit files appears correct.

6 years agotests/gpghome: Create revocation certificates for keys
Dan Nicholson [Fri, 21 Jun 2019 11:27:33 +0000 (06:27 -0500)]
tests/gpghome: Create revocation certificates for keys

These can then be imported during a test to revoke a key without trying
to go through the gpg --generate-revocation dialog. Note that these need
to go in a subdirectory of the homedir since `gpgkeypath` will try to
import every regular file in the homedir.

6 years agotests/libtest: Make temporary gpghome private
Dan Nicholson [Wed, 19 Jun 2019 16:51:47 +0000 (11:51 -0500)]
tests/libtest: Make temporary gpghome private

gpg prints a warning about unsafe permissions if the homedir is group or
world readable. This is just noise in the test logs, so appease it by
making the homedir 700.

6 years agotests/libtest: Record long GPG key IDs and fingerprints
Dan Nicholson [Wed, 19 Jun 2019 14:49:32 +0000 (09:49 -0500)]
tests/libtest: Record long GPG key IDs and fingerprints

Use long GPG key IDs as it's safer and matches the format used by gpg
and gpgme. Add the associated fingerprints since these are needed by gpg
when manipulating keys.

6 years agolib/gpg: Prefer declare-and-initialize style
Dan Nicholson [Wed, 19 Jun 2019 18:08:40 +0000 (13:08 -0500)]
lib/gpg: Prefer declare-and-initialize style

As noted in
https://github.com/ostreedev/ostree/pull/1872#discussion_r295408768.

6 years agoMerge pull request #1993 from dbnicholson/f29-rpmostree-fixes
OpenShift Merge Robot [Wed, 22 Jan 2020 14:01:25 +0000 (15:01 +0100)]
Merge pull request #1993 from dbnicholson/f29-rpmostree-fixes

ci/rpmostree: Bump to 2019.4

6 years agoci/rpmostree: Bump to 2019.4
Dan Nicholson [Tue, 21 Jan 2020 21:56:31 +0000 (14:56 -0700)]
ci/rpmostree: Bump to 2019.4

The vmcheck tests in 2019.3 fail because of an SSH control socket issue
on overlayfs. This is fixed in 2019.4[1]. That has some other changes
such as using Python 3 in tests. The package dependencies have been
synced from the rpm-ostree CI for that.

Unfortunately, this is no longer a totally representative test of f29
since it has 2019.3 in updates. But that's the price you pay for
exercising someone else's CI from your own CI.

1. https://github.com/coreos/rpm-ostree/commit/c89f81c1385ef095616b0e7001926572a20057b2

Fixes: #1994
6 years agoMerge pull request #1991 from dbnicholson/test-fixes
OpenShift Merge Robot [Tue, 21 Jan 2020 20:13:02 +0000 (21:13 +0100)]
Merge pull request #1991 from dbnicholson/test-fixes

tests/core: Really pick C.UTF-8 locale

6 years agotests/core: Really pick C.UTF-8 locale
Dan Nicholson [Tue, 21 Jan 2020 17:25:17 +0000 (10:25 -0700)]
tests/core: Really pick C.UTF-8 locale

The case-ignoring regex `^(C|en_US)` will match any locale that starts
with `c`. On my system this is `ca_AD.utf8`, which breaks the test
suite. Instead, use a single regex that includes the joining `.` rather
than 2 separate regexes. This also changes `head` to use the `-n`
option, which has been preferred for at least 10 years in the coreutils
version and is supported by busybox as well.

6 years agobin/show: Add --print-sizes option to show sizes metadata
Dan Nicholson [Thu, 24 Oct 2019 21:21:49 +0000 (15:21 -0600)]
bin/show: Add --print-sizes option to show sizes metadata

Use the new `ostree_commit_get_object_sizes()` API to read the
`ostree.sizes` commit metadata and print a summary.

6 years agocore: Add ostree_commit_get_object_sizes API
Dan Nicholson [Tue, 21 Jan 2020 02:54:00 +0000 (19:54 -0700)]
core: Add ostree_commit_get_object_sizes API

This function parses the object listing in the `ostree.sizes` metadata
and returns an array of `OstreeCommitSizesEntry` structures.

Unfortunately, for reasons I don't understand, the linker wants to
resolve `_ostree_read_varuint64` from `ostree-core.c` even though it's
not used by `test-checksum.c` at all.

6 years agocore: Add OstreeCommitSizesEntry type
Dan Nicholson [Thu, 19 Dec 2019 19:50:46 +0000 (12:50 -0700)]
core: Add OstreeCommitSizesEntry type

This will be used when reading out entries in the `ostree.sizes`
metadata. Each entry corresponds to an object in the metadata array.

6 years agolibarchive: Support commit sizes metadata
Dan Nicholson [Thu, 24 Oct 2019 23:00:33 +0000 (17:00 -0600)]
libarchive: Support commit sizes metadata

Call the helper to set the generate_sizes boolean so that object size
data is stored while writing the mtree.

6 years agolib/commit: Include object type in sizes metadata
John Hiesey [Thu, 24 Oct 2019 15:10:57 +0000 (09:10 -0600)]
lib/commit: Include object type in sizes metadata

Append a byte encoding the OSTree object type for each object in the
metadata. This allows the commit metadata to be fetched and then for the
program to see which objects it already has for an accurate calculation
of which objects need to be downloaded.

This slightly breaks the `ostree.sizes` `ay` metadata entries. However,
it's unlikely anyone was asserting the length of the entries since the
array currently ends in 2 variable length integers. As far as I know,
the only users of the sizes metadata are the ostree test suite and
Endless' eos-updater[1]. The former is updated here and the latter
already expects this format.

1. https://github.com/endlessm/eos-updater/

6 years agotests/sizes: Check duplicate file doesn't add sizes entry
Dan Nicholson [Wed, 23 Oct 2019 15:43:10 +0000 (09:43 -0600)]
tests/sizes: Check duplicate file doesn't add sizes entry

A duplicate file will resolve to the same object, so it shouldn't add
any entries to the sizes metadata.

6 years agotests/sizes: Test that sizes metadata is not reused
Dan Nicholson [Wed, 23 Oct 2019 15:10:06 +0000 (09:10 -0600)]
tests/sizes: Test that sizes metadata is not reused

Ensure that the object sizes hash table is cleared after a commit and
not only when the repo is closed.

6 years agotests/sizes: Test sizes metadata with existing objects
Dan Nicholson [Tue, 22 Oct 2019 21:14:58 +0000 (15:14 -0600)]
tests/sizes: Test sizes metadata with existing objects

Repeat the commit to make sure that the files are enumerated again for
the size metadata.

6 years agolib/commit: Make size entries for existing objects
Dan Nicholson [Wed, 23 Oct 2019 15:28:11 +0000 (09:28 -0600)]
lib/commit: Make size entries for existing objects

If the object was already in the repo then the sizes metadata entry was
skipped. Move the sizes entry creation after the data has been computed
but before the early return for an existing object.

6 years agolib/commit: Fix object sizes metadata for multiple commits
Dan Nicholson [Wed, 23 Oct 2019 15:12:08 +0000 (09:12 -0600)]
lib/commit: Fix object sizes metadata for multiple commits

The object sizes hash table was only being cleared when the repo was
finalized. That means that performing multiple commits while the repo
was open would reuse all the object sizes metadata for each commit.

Clear the hash table when the sizes metadata is setup and when it's
added to a commit. This still does not fix the issue all the way since
it does nothing to prevent the program from constructing multiple
commits simultaneously. To handle that, the object sizes hash table
should be attached to the MutableTree since that has the commit state.
However, the MutableTree is gone when the commit is actually created.
The hash table would have to be transferred to the root file when
writing the MutableTree. That would be an awkward addition to
OstreeRepoFile, though. Add a FIXME to capture that.

6 years agotests/sizes: Improve metadata validation
Dan Nicholson [Tue, 22 Oct 2019 20:59:19 +0000 (14:59 -0600)]
tests/sizes: Improve metadata validation

Ensure all 3 of the checksum, compressed size and uncompressed size are
correct. For repeatable objects, skip xattrs and use canonical
permissions for the commit. For the sizes, read a varint rather than
assuming they will be a single byte. To work around bugs in gjs with
byte array unpacking, manually build the array byte by byte. Split out
some helper functions to use in subsequent tests.

6 years agolib/commit: Only set generate_sizes for archive repos
Dan Nicholson [Wed, 23 Oct 2019 19:05:48 +0000 (13:05 -0600)]
lib/commit: Only set generate_sizes for archive repos

Rather than checking throughout the code, only set the boolean when
appropriate.

6 years agoMerge pull request #1987 from akiernan/us-switchroot-tests
OpenShift Merge Robot [Thu, 16 Jan 2020 15:47:41 +0000 (16:47 +0100)]
Merge pull request #1987 from akiernan/us-switchroot-tests

Skip /var test if running with systemd and libmount

6 years agoMerge pull request #1988 from akiernan/us-switchroot-installed
OpenShift Merge Robot [Tue, 14 Jan 2020 19:30:33 +0000 (20:30 +0100)]
Merge pull request #1988 from akiernan/us-switchroot-installed

test-switchroot.sh: Find ostree-prepare-root in installed tests

6 years agofixup! test-switchroot.sh: Find ostree-prepare-root in installed tests
Alex Kiernan [Mon, 30 Dec 2019 13:28:35 +0000 (13:28 +0000)]
fixup! test-switchroot.sh: Find ostree-prepare-root in installed tests

6 years agotest-switchroot.sh: Find ostree-prepare-root in installed tests
Alex Kiernan [Sun, 29 Dec 2019 12:43:34 +0000 (12:43 +0000)]
test-switchroot.sh: Find ostree-prepare-root in installed tests

When running with installed tests, ostree-prepare-root (probably)
exists in /usr/lib. Add heuristics to look for it based on the directory
we're running from.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
6 years agotests: Skip /var test if running with systemd and libmount
Alex Kiernan [Sun, 29 Dec 2019 13:25:24 +0000 (13:25 +0000)]
tests: Skip /var test if running with systemd and libmount

If running with systemd and libmount then /var mounting is deferred for
systemd. Skip the relevant tests in this case as it will always fail.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
6 years agobuild: Expose systemd in OSTREE_FEATURES
Alex Kiernan [Sun, 29 Dec 2019 13:23:23 +0000 (13:23 +0000)]
build: Expose systemd in OSTREE_FEATURES

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
6 years agotest-switchroot.sh: Exclude /proc from file list
Alex Kiernan [Sun, 29 Dec 2019 12:32:28 +0000 (12:32 +0000)]
test-switchroot.sh: Exclude /proc from file list

Since we're not interested in any file inside /proc, exclude it from the
file listing in our fake root thus avoiding failures when processes die
during our execution and find(1) can't then look inside those
directories.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
6 years agoMerge pull request #1767 from cgwalters/sysroot-mnt-namespace
OpenShift Merge Robot [Wed, 11 Dec 2019 20:34:36 +0000 (21:34 +0100)]
Merge pull request #1767 from cgwalters/sysroot-mnt-namespace

Support mounting /sysroot (and /boot) read-only